<?php

namespace App\Index;

use App\Controller;
use Helper\ValidateCode;

/**
 * @title    验证码
 * @rank    99
 */
// hook index_captcha_use.php

class Captcha extends Controller
{
    // hook index_captcha_start.php
    public bool $not_closed = true;
    /**
     * @title    验证码
     * @rank    99
     */
    public function action_Index_GET()
    {
        $name = $this->request->param('name');
        $num = min(10, max(4, $this->request->param('num', 4)));
        // hook index_captcha_index_get_start.php

        $_vc = new ValidateCode($this->_response);  //实例化一个对象
        $img = $_vc->do_img($num);
        $_vc->getCode($name);
        // hook index_captcha_index_get_end.php
        $this->response('0000',['data'=>$img], 'image/png','',1000);
    }

    // hook index_captcha_end.php
}

?>